﻿Chenxin.UI.FavorManage=Chenxin.extend(Chenxin.UI.PageCommon,{
	autoInitForm:false,
	actionUrl:'service/favorite.ashx',
	createGrid:function(){
		// return new Chenxin.UI.Pagination({
			// actionUrl:this.actionUrl+'?op=getlist',
			// id:'favor',
			// renderTo:'favor_table'
			
		// });
		var _this = this;
		_this.showtype = 10;
		return new Chenxin.UI.JsonGrid({
			actionUrl:this.actionUrl+'?op=getlist',
			pageSize: 50,
			height: 400,
			renderTo:'favor_table',
			hasCheckBox:false,
			id:'favor',
			title:'我的收藏列表',
			baseParam: { showtype: 10 },
			scope:this,
			autoLoad: true,
			cellAlign: 'left',
			cellBorder: true,
			createTitleTool: function() {
                return [{
                    text: '<span class="simple"></span>房源收藏',
                    scope: _this,
                    title: '房源收藏',
                    handler: function(el) {
                        this.showTypeGrid(10, el.title);
                        _this.showtype = 10;
                    }
                    }, {
                    text: '<span class="simple"></span>客户收藏',
                    scope: _this,
                    title: '客户收藏',
                    handler: function(el) {
                        this.showTypeGrid(20, el.title);
                        _this.showtype = 20;
                    }
                }];
            },
			modelId:'RecordId'
		});
	},
	showTypeGrid: function(showtype, title) {
        showtype = showtype || 10;
        if (this.grid.baseParam.showtype != showtype) {
            this.grid.baseParam.showtype = showtype;
            this.grid.reload();
            this.grid.setTitle(title + '列表');
        }
    },		
	cancle:function(){
	},
	initEvent:function(){
		var _this=this;
		$('.a_favor_remove').live('click',function(){
			_this.currentId=this.name;
			_this.del();
		});
		
		$('#btn_del').live('click',function(){
			_this.del();
		});
	},
	
	createSearch:function(){
		return new Chenxin.UI.FavorManageSearch({
			scope:this
		});
	},
	initComponent:function(){
		Chenxin.UI.FavorManage.superclass.initComponent.call(this);
	}
});
var columns = {
    /**房源收藏*/
    houseFavorHead: {
        RecordId: {
            create: false,
            width: 100,
            head: 'RecordId'
        },
        Community: {
            width: 180,
            head: '房源地址',
            sortable: true,
            style: 'text-align:left;text-indent:2px;',
            renderer: function(val, c, row) {
                return '<a href="/ShowDetailInfo.aspx?houseid=' + row.HouseId + '" target="_blank">' + val + '</a>';
            }
        },
        BuildingArea: {
            width: 180,
            head: '面积',
            sortable: true
        },
        Model_Room: {
            width: 100,
            head: '房型',
            sortable: true,
            renderer: function(val, c, row) {
                var _v = val;
                if (_v) {
                    val += '室';
                }
                if (row.Model_Hall) {
                    _v += row.Model_Hall + '厅';
                }
                if (row.Model_Toilet) {
                    _v += row.Model_Toilet + '卫';
                }
                if (row.Model_Balcony) {
                    _v += row.Model_Balcony + '阳台';
                }
                return _v
            }
        },
        SalePrice_T: {
            width: 100,
            head: '总价',
            sortable: true
        },
        SalePrice_U: {
            width: 80,
            head: '单价',
            sortable: true
        },
        RentPrice: {
            width: 130,
            head: '租价',
            sortable: true
        },
        Region: {
            width: 40,
            head: '区域',
            sortable: true
        },
        Address: {
            width: 150,
            head: '地址',
            sortable: true
        },
        Status: {
            width: 40,
            head: '状态',
            renderer: function(val) {
                var _v = '';
                switch (val) {
                    case 10:
                        _v = '有效';
                        break;
                    case 20:
                        _v = '暂缓';
                        break;
                    case 30:
                        _v = '封盘';
                        break;
                    case -1:
                        _v = '无效';
                        break;
                }
                return _v;
            }
        },
        OprDepart: {
            width: 100,
            head: '部门',
            sortable: true
        },
        OprPerson: {
            width: 70,
            head: '业务员',
            sortable: true
        },
        AddTime: {
            width: 80,
            head: '收藏时间',
            sortable: true
        }
    },
    /**客户收藏*/
    customerFavorHead: {
        RecordId: {
            create: false,
            width: 100,
            head: 'RecordId'
        },
        Customer: {
            width: 180,
            head: '客户姓名',
            sortable: true,
            style: 'text-align:left;text-indent:2px;'
        },
        CustomerCode: {
            width: 180,
            head: '编号',
            sortable: true
        },
        Mobile: {
            width: 100,
            head: '手机号码',
            sortable: true
        },
        Phone: {
            width: 100,
            head: '电话号码',
            sortable: true
        },
        CertificateType: {
            width: 80,
            head: '证件类型',
            sortable: true
        },
        CertificateNo: {
            width: 130,
            head: '证件号码',
            sortable: true
        },
        Region: {
            width: 40,
            head: '区域',
            sortable: true
        },
        Address: {
            width: 150,
            head: '地址',
            sortable: true
        },
        Status: {
            width: 40,
            head: '状态',
            renderer: function(val) {
                var _v = '';
                switch (val) {
                    case 10:
                        _v = '有效';
                        break;
                    case 20:
                        _v = '暂缓';
                        break;
                    case 30:
                        _v = '封盘';
                        break;
                    case -1:
                        _v = '无效';
                        break;
                }
                return _v;
            }
        },
        OprDepart: {
            width: 100,
            head: '部门',
            sortable: true
        },
        OprPerson: {
            width: 70,
            head: '业务员',
            sortable: true
        },
        AddTime: {
            width: 80,
            head: '收藏时间',
            sortable: true
        }
    }
}

/**
*查询面板
*/
Chenxin.UI.FavorManageSearch=Chenxin.extend(Chenxin.UI.SearchCommon,{
	id:'favor_search',
	initEvent:function(){
		var _this=this;
		$('#btn_search').click(function(){
			_this.scope.reloadGrid();
		});
	},
	createComboList:function(){
		var status=new Chenxin.UI.Combo({
				containerId:'#favortype',
				tbxWidth:70,
				items:comboCommon.favorType
			});
		
		return [status];
	},
	initComponent:function(){
		Chenxin.UI.FavorManageSearch.superclass.initComponent.call(this);
	}
});


$(document).ready(function(){
	var favorMgr=new Chenxin.UI.FavorManage();	
});





